home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F16716_StandardSnippetLibrary.xml < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-28  |  24.5 KB  |  251 lines

  1.  ■<?xml version="1.0" encoding="UTF-16"?>
  2. <xselerator_snippet_library>
  3. <snippet favourite="yes">
  4. <hotkey>24644</hotkey>
  5. <short_description><![CDATA[XPath Uppercase]]></short_description>
  6. <full_description><![CDATA[XPath uppercase function]]></full_description>
  7. <fragment type="simple"><![CDATA[translate(^^here^^,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')]]></fragment>
  8. </snippet>
  9. <snippet favourite="yes">
  10. <short_description><![CDATA[XPath Lowercase]]></short_description>
  11. <full_description><![CDATA[XPath lowercase function]]></full_description>
  12. <fragment type="simple"><![CDATA[translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')]]></fragment>
  13. </snippet>
  14. <snippet favourite="yes">
  15. <short_description><![CDATA[XPath ABS() Function]]></short_description>
  16. <full_description><![CDATA[Perform ABS() in XPath]]></full_description>
  17. <fragment type="simple"><![CDATA[concat(substring('-',2 - (. &lt; 0)), '1') * .]]></fragment>
  18. </snippet>
  19. <snippet favourite="yes">
  20. <short_description><![CDATA[HTML/ISO-88591-1 xsl:output]]></short_description>
  21. <full_description><![CDATA[xsl:output with presets for
  22.   method: html
  23.   encoding: ISO-88591-1
  24.   doctype-public: -//W3C//DTD HTML 4.0 Transitional//EN]]></full_description>
  25. <stylesheet_fragment><![CDATA[<xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" />]]></stylesheet_fragment>
  26. </snippet>
  27. <snippet favourite="yes">
  28. <short_description><![CDATA[Quick choose/when/otherwise]]></short_description>
  29. <full_description><![CDATA[Pre-built xsl:choose/xsl:when/xsl:otherwise statements]]></full_description>
  30. <fragment type="indented"><![CDATA[  <xsl:choose>
  31.     <xsl:when test="">
  32.             
  33.     </xsl:when>
  34.     <xsl:otherwise>
  35.             
  36.     </xsl:otherwise>
  37.   </xsl:choose>]]></fragment>
  38. </snippet>
  39. <snippet favourite="yes">
  40. <short_description><![CDATA[Template comment]]></short_description>
  41. <full_description><![CDATA[Comment for template]]></full_description>
  42. <fragment type="simple"><![CDATA[<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  43.   Template:
  44.   Description:
  45.   Parameters:-
  46.   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->]]></fragment>
  47. </snippet>
  48. <snippet favourite="yes">
  49. <short_description><![CDATA[Inner comment]]></short_description>
  50. <full_description><![CDATA[Comment with begin and end lines]]></full_description>
  51. <fragment type="indented"><![CDATA[<!-- =========================================================================
  52. ============================================================================== -->]]></fragment>
  53. </snippet>
  54. <snippet favourite="yes">
  55. <short_description><![CDATA[XSL Namespace (XSLT)]]></short_description>
  56. <full_description><![CDATA[xmlns:xsl="http://www.w3.org/1999/XSL/Transform"]]></full_description>
  57. <fragment type="simple"><![CDATA[xmlns:xsl="http://www.w3.org/1999/XSL/Transform"]]></fragment>
  58. </snippet>
  59. <snippet favourite="yes">
  60. <short_description><![CDATA[MS-XSL Namespace]]></short_description>
  61. <full_description><![CDATA[xmlns:msxsl="urn:schemas-microsoft-com:xslt"]]></full_description>
  62. <fragment type="simple"><![CDATA[xmlns:msxsl="urn:schemas-microsoft-com:xslt"]]></fragment>
  63. </snippet>
  64. <snippet favourite="yes">
  65. <short_description><![CDATA[XSL Namespace (XSL-WD)]]></short_description>
  66. <full_description><![CDATA[xmlns:xsl="http://www.w3.org/TR/WD-xsl"]]></full_description>
  67. <fragment type="simple"><![CDATA[xmlns:xsl="http://www.w3.org/TR/WD-xsl"]]></fragment>
  68. </snippet>
  69. <snippet favourite="no">
  70. <short_description><![CDATA[Template: Bin2Dec]]></short_description>
  71. <full_description><![CDATA[Convert binary string to decimal value]]></full_description>
  72. <new_template_fragment><![CDATA[<!-- ========================================================= -->
  73. <!-- Function: Bin2Dec(<value>) => Decimal value               -->
  74. <!-- Parameters:-                                              -->
  75. <!--   <value>  - the binary string to be converted to decimal -->
  76. <xsl:template name="Bin2Dec">
  77.     <xsl:param name="value" select="'0'"/>
  78.     <!-- the following paremeters are used only during recursion -->
  79.     <xsl:param name="bin-power" select="number(1)"/>
  80.     <xsl:param name="accum" select="number(0)"/>
  81.     <!-- isolate last binary digit  -->
  82.     <xsl:variable name="bin-digit" select="substring($value,string-length($value),1)"/>
  83.     <!-- check that binary digit is valid -->
  84.     <xsl:choose>
  85.         <xsl:when test="not(contains('01',$bin-digit))">
  86.             <!-- not a binary digit! -->
  87.             <xsl:text>NaN</xsl:text>
  88.         </xsl:when>
  89.         <xsl:when test="string-length($bin-digit) = 0">
  90.             <!-- unexpected end of hex string -->
  91.             <xsl:text>0</xsl:text>
  92.         </xsl:when>
  93.         <xsl:otherwise>
  94.             <!-- OK so far -->
  95.             <xsl:variable name="remainder" select="substring($value,1,string-length($value)-1)"/>
  96.             <xsl:variable name="this-digit-value" select="number($bin-digit) * $bin-power"/>
  97.             <!-- determine whether this is the end of the hex string -->
  98.             <xsl:choose>
  99.                 <xsl:when test="string-length($remainder) = 0">
  100.                     <!-- end - output final result -->
  101.                     <xsl:value-of select="$accum + $this-digit-value"/>
  102.                 </xsl:when>
  103.                 <xsl:otherwise>
  104.                     <!-- recurse to self for next digit -->
  105.                     <xsl:call-template name="Bin2Dec">
  106.                         <xsl:with-param name="value" select="$remainder"/>
  107.                         <xsl:with-param name="bin-power" select="$bin-power * 2"/>
  108.                         <xsl:with-param name="accum" select="$accum + $this-digit-value"/>
  109.                     </xsl:call-template>
  110.                 </xsl:otherwise>
  111.             </xsl:choose>
  112.         </xsl:otherwise>
  113.     </xsl:choose>
  114. </xsl:template>]]></new_template_fragment>
  115. </snippet>
  116. <snippet favourite="no">
  117. <short_description><![CDATA[Template: Hex2Dec]]></short_description>
  118. <full_description><![CDATA[Convert a hex string to decimal value]]></full_description>
  119. <new_template_fragment><![CDATA[<!-- ======================================================== -->
  120. <!-- Function: Hex2Dec(<value>) => Decimal value              -->
  121. <!-- Parameters:-                                             -->
  122. <!--   <value>  - the hex string to be converted to decimal   -->
  123. <!--              (case of hex string is unimportant)         -->
  124. <xsl:template name="Hex2Dec">
  125.     <xsl:param name="value" select="'0'"/>
  126.     <!-- the following paremeters are used only during recursion -->
  127.     <xsl:param name="hex-power" select="number(1)"/>
  128.     <xsl:param name="accum" select="number(0)"/>
  129.     <!-- isolate last hex digit (and convert it to upper case) -->
  130.     <xsl:variable name="hex-digit" select="translate(substring($value,string-length($value),1),'abcdef','ABCDEF')"/>
  131.     <!-- check that hex digit is valid -->
  132.     <xsl:choose>
  133.         <xsl:when test="not(contains('0123456789ABCDEF',$hex-digit))">
  134.             <!-- not a hex digit! -->
  135.             <xsl:text>NaN</xsl:text>
  136.         </xsl:when>
  137.         <xsl:when test="string-length($hex-digit) = 0">
  138.             <!-- unexpected end of hex string -->
  139.             <xsl:text>0</xsl:text>
  140.         </xsl:when>
  141.         <xsl:otherwise>
  142.             <!-- OK so far -->
  143.             <xsl:variable name="remainder" select="substring($value,1,string-length($value)-1)"/>
  144.             <xsl:variable name="this-digit-value" select="string-length(substring-before('0123456789ABCDEF',$hex-digit)) * $hex-power"/>
  145.             <!-- determine whether this is the end of the hex string -->
  146.             <xsl:choose>
  147.                 <xsl:when test="string-length($remainder) = 0">
  148.                     <!-- end - output final result -->
  149.                     <xsl:value-of select="$accum + $this-digit-value"/>
  150.                 </xsl:when>
  151.                 <xsl:otherwise>
  152.                     <!-- recurse to self for next digit -->
  153.                     <xsl:call-template name="Hex2Dec">
  154.                         <xsl:with-param name="value" select="$remainder"/>
  155.                         <xsl:with-param name="hex-power" select="$hex-power * 16"/>
  156.                         <xsl:with-param name="accum" select="$accum + $this-digit-value"/>
  157.                     </xsl:call-template>
  158.                 </xsl:otherwise>
  159.             </xsl:choose>
  160.         </xsl:otherwise>
  161.     </xsl:choose>
  162. </xsl:template>]]></new_template_fragment>
  163. </snippet>
  164. <snippet favourite="no">
  165. <short_description><![CDATA[Template: Dec2Hex]]></short_description>
  166. <full_description><![CDATA[Convert a decimal value to hex string]]></full_description>
  167. <new_template_fragment><![CDATA[<!-- ===================================================== -->
  168. <!-- Function: Dec2Hex(<value>[,<digits>]) => Hex string   -->
  169. <!-- Parameters:-                                          -->
  170. <!--   <value>  - the decimal value to be converted to hex -->
  171. <!--              (must be a positive)                     -->
  172. <!--   <digits> - the number of hex digits required        -->
  173. <!--              If this parameter is omitted then the    -->
  174. <!--              hex string returned is as long as reqd.  -->
  175. <!--              If the number of digits required exceeds -->
  176. <!--              the value specified by this parameter    -->
  177. <!--              then the hex string is as long as reqd.  --> 
  178. <xsl:template name="Dec2Hex">
  179.     <xsl:param name="value" select="number(0)"/>
  180.     <xsl:param name="digits" select="number(-1)"/>
  181.     <!-- the following paremeters are used only during recursion -->
  182.     <xsl:param name="hex" select="number(268435456)"/>
  183.     <xsl:param name="hex-power" select="number(28)"/>
  184.     <xsl:param name="nonzero-encounters" select="false()"/>
  185.     <!-- calculate the left over value to be passed to next recursion -->
  186.     <xsl:variable name="remainder" select="floor($value) mod $hex"/>
  187.     <!-- calculate the value of this nybble (this hex digit) -->
  188.     <xsl:variable name="this-nybble" select="(floor($value) - $remainder) div ($hex)"/>
  189.     <!-- determine whether a non-zero digit has been encountered yet -->
  190.     <xsl:variable name="nonzero-encountered" select="boolean($nonzero-encounters or ($this-nybble &gt; 0))"/>
  191.     <!-- only output hex digit if:-                   -->
  192.     <!--     non-zero has already been encountered OR -->
  193.     <!--     on the last digit OR                     -->
  194.     <!--     the number of required digits says so    -->
  195.     <xsl:if test="$nonzero-encountered or ($hex-power = 0) or ((($hex-power div 4) + 1) &lt;= $digits)">
  196.         <xsl:value-of select="substring('0123456789ABCDEF',($this-nybble)+1,1)"/>
  197.     </xsl:if>
  198.     <!-- recursive call until all digits have been dealt with -->
  199.     <xsl:if test="$hex-power &gt; 0">
  200.         <xsl:call-template name="Dec2Hex">
  201.             <xsl:with-param name="value" select="$remainder"/>
  202.             <xsl:with-param name="hex" select="$hex div 16"/>
  203.             <xsl:with-param name="hex-power" select="$hex-power - 4"/>
  204.             <xsl:with-param name="digits" select="$digits"/>
  205.             <xsl:with-param name="nonzero-encounters" select="$nonzero-encountered"/>
  206.         </xsl:call-template>
  207.     </xsl:if>
  208. </xsl:template>]]></new_template_fragment>
  209. </snippet>
  210. <snippet favourite="no">
  211. <short_description><![CDATA[Template: Dec2Bin]]></short_description>
  212. <full_description><![CDATA[Convert a decimal value to binary string]]></full_description>
  213. <new_template_fragment><![CDATA[<!-- ======================================================== -->
  214. <!-- Function: Dec2Bin(<value>) => Binary string              -->
  215. <!-- Parameters:-                                             -->
  216. <!--   <value>  - the decimal value to be converted to binary -->
  217. <!--              (must be a positive)                        -->
  218. <xsl:template name="Dec2Bin">
  219.     <xsl:param name="value" select="number(0)"/>
  220.     <!-- the following paremeters are used only during recursion -->
  221.     <xsl:param name="bin" select="number(2147483648)"/>
  222.     <xsl:param name="bin-power" select="number(31)"/>
  223.     <xsl:param name="one-encounters" select="false()"/>
  224.     <!-- calculate the left over value to be passed to next recursion -->
  225.     <xsl:variable name="remainder" select="$value mod $bin"/>
  226.     <!-- calculate the value of this bit (this binary digit) -->
  227.     <xsl:variable name="this-bit" select="$value - $remainder"/>
  228.     <!-- determine whether a non-zero digit has been encountered yet -->
  229.     <xsl:variable name="one-encountered" select="boolean($one-encounters or ($this-bit &gt; 0))"/>
  230.     <!-- only output digit if:                        -->
  231.     <!--     non-zero has already been encountered OR -->
  232.     <!--     on the last digit                        -->
  233.     <xsl:if test="$one-encountered or ($bin-power = 0)">
  234.         <xsl:value-of select="substring('01',($this-bit div $bin)+1,1)"/>
  235.     </xsl:if>
  236.     <!-- recursive call until all digits have been dealt with -->
  237.     <xsl:if test="$bin-power &gt; 0">
  238.         <xsl:call-template name="Dec2Bin">
  239.             <xsl:with-param name="value" select="$remainder"/>
  240.             <xsl:with-param name="bin" select="$bin div 2"/>
  241.             <xsl:with-param name="bin-power" select="$bin-power - 1"/>
  242.             <xsl:with-param name="one-encounters" select="$one-encountered"/>
  243.         </xsl:call-template>
  244.     </xsl:if>
  245. </xsl:template>]]></new_template_fragment>
  246. </snippet>
  247. </xselerator_snippet_library>